<template>
	<div class="hd-box">
		<div class="hd-title-box fw-700 fs-32">
			<div class="title">
				中山市小榄电动自行车监管平台
			</div>
			<div class="label-box fs-16">
				<div>智慧感知</div>
				<div>覆盖全面</div>
				<div>运转高效</div>
			</div>
		</div>
		<div class="hd-operation">
			<div class="hd-operation-box">
				<div class="hd-operation-item time-box">
					<div>
						<img src="../../assets/images/time.png">
					</div>
					<div style="color: #9dcbef;" class="fs-16">
						<div>{{nowDate + '-' + nowTime}}</div>
					</div>
				</div>
				<div class="hd-operation-item user-box">
					<div>
						<img src="../../assets/images/user.png">
					</div>
					<div style="color: #00b5ec;">
						<div class="fs-16">{{username ?username : 'super'}}</div>
					</div>
				</div>
				<div class="hd-operation-item">
					<img src="../../assets/images/fullscreen.png" @click="screenfull">
					<img src="../../assets/images/exit.png" @click="toLogin">
				</div>
			</div>
			<div>
			</div>
		</div>
	</div>
</template>

<script>
	export default {
		data() {
			return {
				nowDate: "", // 当前日期
				nowTime: "", // 当前时间
				nowWeek: "", // 当前星期
				username: ''
			}
		},
		mounted() {
			this.currentTime();
			this.username = sessionStorage.getItem('username');
		},
		methods: {
			screenfull(event) {
				if (document.fullscreenElement) {
					// 退出全屏
					console.log('退出全屏')
					document.exitFullscreen();
				} else {
					// 全屏显示
					console.log('全屏显示')
					document.documentElement.requestFullscreen();
				}
			},
			// 进入后台
			toManage() {
				this.$router.replace("/home");
			},
			currentTime() {
				setInterval(this.getDate, 500);
			},
			getDate() {
				let self = this;
				let yy = new Date().getFullYear();
				let mm = new Date().getMonth() + 1;
				let dd = new Date().getDate();
				let week = new Date().getDay();
				let hh = new Date().getHours();
				let mf =
					new Date().getMinutes() < 10 ?
					"0" + new Date().getMinutes() :
					new Date().getMinutes();
				let ss = new Date().getSeconds().toString();
				ss = ss.length < 2 ? '0' + ss : ss;
				switch (week) {
					case 1:
						self.nowWeek = "星期一";
						break;
					case 2:
						self.nowWeek = "星期二";
						break;
					case 3:
						self.nowWeek = "星期三";
						break;
					case 4:
						self.nowWeek = "星期四";
						break;
					case 5:
						self.nowWeek = "星期五";
						break;
					case 6:
						self.nowWeek = "星期六";
						break;
					case 0:
						self.nowWeek = "星期日";
				}
				self.nowTime = hh + ":" + mf + ":" + ss;
				self.nowDate = yy + "-" + mm + "-" + dd;
			},
			toLogin() {
				let self = this;
				window.open('http://14.29.143.198:9080/admin/auth/logout', '_self')
			}
		}
	}
</script>

<style>
</style>
